package com.book.activeMQ.consumers;

import com.book.service.TempOrderService;
import com.book.service.domain.OrderCreateTempMqService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * @version 1.0
 * @Author Jincheng.Li
 * @Date 2021/6/4 8:47 下午
 * @Project_Name graduation-project
 */
@Component
@Slf4j
public class ResetOrderMQ implements MessageListener {
    @Autowired
    private TempOrderService tempOrderService;
    @Autowired
    private OrderCreateTempMqService orderCreateTempMqService;

    @Override
    public void onMessage(Message message) {
        try {
            String orderNo = ((TextMessage) message).getText();
            log.info("SaveOrderDetail#orderNo:{}", orderNo);
            if (StringUtils.isEmpty(orderNo)) {
                return;
            }
            orderCreateTempMqService.cancelOrder(orderNo);
        } catch (Exception e) {
            return;
        }

    }
}
